/*
 * Copyright (c) 2012.
 * Keerthi Ramachandran
 * You are free to copy/modify/share the programs
 */

package com.kee.example;

import com.kee.example.domain.Event;
import com.kee.example.util.HibernateUtil;
import org.hibernate.Session;

import java.util.Date;

/**
 * Created with IntelliJ IDEA.
 * User: keerthi
 * Date: 12/8/125:46 PM
 */
public class EventRunner {

    public static final String EVENT_STRING = "Event String";
    public static final Date EVENT_DATE = new Date();

    public static void main(String[] args) {
        EventRunner runner = new EventRunner();
        runner.createAndStoreEvent();

        HibernateUtil.getSessionFactory().close();
    }

    private void createAndStoreEvent() {
        Session session = HibernateUtil.getSessionFactory().getCurrentSession();
        session.beginTransaction();
        Event event = new Event();
        event.setEventDate(EVENT_DATE);
        event.setEventString(EVENT_STRING);
        session.save(event);
        session.getTransaction().commit();
    }
}
